//  Vue.directive('指令名',配置对象)
export const imgerror = {
  inserted(el, binding) { // el表示的是使用指令的dom元素
    // console.log(el, binding.value)
    // 图片加载失败后触发onerror再设置默认头像
    el.onerror = function() {
      // console.log('图片裂开啦')
      // el.src = 'https://img0.baidu.com/it/u=2996250653,3603163890&fm=26&fmt=auto'
      el.src = binding.value || 'https://img0.baidu.com/it/u=2996250653,3603163890&fm=26&fmt=auto'
    }
  }
}

export const red = {
  inserted(el) {
    el.style.color = 'red'
  }
}
